    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   1

          1                         ;^Z80^
          3                         ;NAME ^Rev 6 - DTT^
          4
          5                         DESCR_               MACRO
          6                                                .GOTO ENDESCR_1
          7
          8                          Author:       DTT
          9                          Project:      ________, ___
         10                          Starting date:18feb83
         11
         12                          Prom release Date:
         13                          Prom release Rev:
         14
         15                          Header Rev: 3
         16
         17                          ********************************
         18                          *                              *
         19                          *  TAPE_MANAGER    DTT         *
         20                          *                              *
         21                          ********************************
         22
         23                                Rev History (one line note indicating the change)
         24
         25                                Rev.  Date         Name      Change
         26                                 6    11/16/83  DTT       ADDED DEVICE ID TO SIMULATE DEVICE INDEPENDENCE
         27                                 5    12spt83   DTT       MODIFIED ERROR SYSTEM TO WRITE ERRORS TO CSA AREA
         28                                 4    08aug83   DTT       SIMULATES WRITES!
         29                                 3    07jul83   DTT       ADDED KILL_TAPE/CSA
         30                                 2    30jun83   DTT       STATE MACHINE FOR MULTI TASKING
         31                                 1    05apr83   DTT       BINK ON I/O ERROR, REMOVING TIMING STUFF, EI AND DI ADDED.
         32                                 0    10feb83   DTT       Initial Pseudo Code
         33
         34                          NAME: TAPE_MANAGER  (OVERLAY CONTROL)
         35
         36
         37                          FUNCTION: (LOAD OVERLAYS VIA SIMULATED I/O WITH THE HP64000)
         38
         39
         40                          INPUTS:   (ACCUMULATOR = OVERLAY NUMBER)
         41
         42
         43                          OUTPUTS:  (OVERLAY IS LOADED TO RAM ADDRESS)
         44
         45
         46                          PSEUDOCODE:  (PASCAL type pseudocode of procedure.)
         47
         48
         49
         50                                  ----------------     overlay request? Y       ----------------
         51                                 :                :----------------------->    :                :
         52                           :---->:    IDLE        :                            :    RENAME      :
         53                           :     :                :                            :                :
         54                           :     :                :---------:                  :                :
         55                           :      ----------------          :                   ----------------
         56                           :                /:\   overlay request? N                    :

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   2

         57                           :                 :______________:                           :
         58                           :                                                            :
         59                           :                                                            :
         60                           :                                                            :
         61                           :                                                            :
         62                           :                                                            :
         63                           :                                                            :
         64                           :                                                           \:/
         65                           :      ----------------                              ----------------
         66                           :     :                :                            :                :
         67                           :     :    READ        : <--------------------------:      OPEN      :
         68                           :     :    FIRST       :                            :                :
         69                           :     :    RECORD      :                            :                :
         70                           :      ------:---------                              ----------------
         71                           :            :
         72                           :            :
         73                           :           \:/
         74                           :      ----------------                              ----------------
         75                           :     :                :------------------------>   :                :
         76                           :     :    READ        :                            :    MOVE DATA   :
         77                           :     :    DATA        :    end of file? N          :   FROM BUFFER  :
         78                           :     :    RECORD      : <--------------------------:      TO RAM    :
         79                           :      ----------------                              --------:-------
         80                           :                                                            :
         81                           :                                                      end of file? Y
         82                           :                                                           \:/
         83                           :      ----------------                              ----------------
         84                           :     :                :                            :                :
         85                            -----: PRE IDLE STATE :<---------------------------:      CLOSE     :
         86                                 :(WAIT FOR CLOSE):                            :                :
         87                                 :                :                            :                :
         88                                  ----------------                              ----------------
         89                         ENDESCR_1       MEND
         90
         91                         DESC_a              MACRO
         92                          .GOTO              DESC_a
         93                          ***********************************************************************************************
         94                           Each transition state looks like this:
         95
         96
         97                            from previous
         98                         =================:
         99                               state      :
        100                                         \:/
        101                                   ----------------:                      -----------------
        102                                  :                :  I/O errors? Y      :                 :
        103                                  : TRANSITION     :-------------------> :  ERROR STATE    :
        104                             :===>:                :                     :  (terminate)    :----:
        105                             :    :                :=====:               :                 :    :
        106                             :     ----------------      :                ----------:------     :
        107                             :            :              :                         /:\          :
        108                             :            :              :                          :           :
        109                             :  sim i/o   :             \:/                         :___________:
        110                              ------------         ---------------- to state 6
        111                                function          :                :============>
        112                                complete? N       : TEST FOR       :
        113                                                  : ABORT          :to state 7

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   3

        114                                                  : REQUEST        :============>
        115                                                   ----------------
        116                                                    no   :
        117                                                  abort  : to next
        118                                                         : state
        119                                                        \:/
        120
        121                         DESC_a          MEND
        122
        123                         DESC_2          MACRO
        124                          .GOTO          DESC_2
        125                         *
        126                         ***************************************************************************************
        127                         *
        128
        129                             COMMON ATTRIBUTE AREAS (COMMUNICATION BUFFER WITH HP)
        130                             ALL VALUES ARE HEXADECIMAL
        131
        132                             1) ASSIGN FILENAME TO CA
        133                                 CA      CA+1     CA+2             CA+n
        134                              -------- -------- -------- -------- -------- -------- -------- --------
        135                             :   8A   :LENGTH  :FILENAME ------> : USER ID         :  NOT
        136                             :        :BYTE    :UP TO 9 BYTES    : UP TO 5 BYTES   :  USED----->
        137                              -------- -------- -------- -------- -------- -------- -------- --------
        138                              LENGTH_BYTE := (((((LENGTH OF FILE NAME)+1)/2)-1)*32) + ((LENGTH OF USER ID)/2)*8)
        139                              FILENAME MUST BE ODD NUMBER OF BYTES LONG MAY BE PADDED WITH ONE SPACE.
        140                              USER ID MUST BE EVEN NUMBER OF BYTES LONG MAY BE PADDED WITH ONE SPACE.
        141
        142                             2) OPEN
        143                                 CA      CA+1     CA+2
        144                              -------- -------- -------- -------- -------- -------- -------- --------
        145                             :   81   :   04   :   00   : NOT
        146                             :        :        :        : USED------------------------------->
        147                              -------- -------- -------- -------- -------- -------- -------- --------
        148                              CA+1 MUST BE 04HEX DESIGNATES ABSOLUTE FILE WILL BE OPENED.
        149                              CA+2 MUST BE 00HEX DESIGNATES DISK NUMBER.
        150
        151                             3) CLOSE
        152                                 CA
        153                              -------- -------- -------- -------- -------- -------- -------- --------
        154                             :   82   :  NOT
        155                             :        :  USED ----------------------------------------------->
        156                              -------- -------- -------- -------- -------- -------- -------- --------
        157
        158                             4) READ
        159                                 CA      CA+1     CA+2              CA+4              CA+6
        160                              -------- -------- -------- -------- -------- -------- -------- --------
        161                             :   87   :   80   : #BYTES TO LOAD  :  N/A   :  N/A   : LOAD ADDRESS
        162                             :        :        :  MSB   :  LSB   :        :        :  MSB   :  LSB
        163                              -------- -------- -------- -------- -------- -------- -------- --------
        164                              CA+1 DEFINES THE BUFFER LENGTH IN WORDS - 1 MUST BE LOADED BEFORE CALLING SIM I/O
        165                              CA+2 DEFINES NUMBER OF BYTES TO MOVE TO RAM FROM THE SIM I/O BUFFER
        166                              CA+6 DEFINES THE RAM ADDRESS TO LOAD TO
        167                              CA+8 (NOT SHOWN) IS THE START OF THE SIM I/O BUFFER
        168                              NOTE: CA+2 AND CA+6 ARE ONE WORD LONG BUT NOT STORED AS Z80 WORDS.
        169                                    THE Z80 EXPECTS WORD VALUES TO BE STORED LSB/MSB.
        170

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   4

        171                         DESC_2
        172                                MEND
        173
        174
        175
        176                         NEXT_STATE      MACRO LP1
        177                                  LD     A,LP1                          ;SOMETHING IN THE COMMAND BUFFER!
        178                                  LD     [TAPE_STATE],A
        179                                  LD     HL,[STATE_VECTORS+LP1+LP1]
        180                                  LD     [NEXT_STATE_ADDRESS],HL
        181                                  JP     END_OF_STATE_MACHINE
        182                                         MEND
        183                         ;SUBROUTINES CALLED:
        184                         ;      EXT
        185
        186                         ;OPERATING SYSTEM CALLS:
        187
        188                         ;EXTERNAL DATA AREAS USED:
        189                                         EXT KILL_TAPE
        190                                         EXT WRITE_TAPE
        191                                         EXT CSA
        192                                         EXT TAPE_STATE
        193                                         EXT OVERLAY_NUMBER
        194
        195                         ;GLOBAL DATA AREAS DEFINED:
        196                                  GLOBAL DEVICE_ID
        197
        198                         ;LOCAL EQUATES
        199           7400          CA       EQU    07400H                         ;COMMON ATTRIBUTES AREA FOR SIM I/O
        200           7401          BUF_LEN  EQU    CA+1
        201           7401          FILETYPE EQU    CA+1                           ;FILETYPE ADDRESS IN C_A_
        202           7402          DISC_NUM EQU    FILETYPE+1                     ;DISK NUMBER ADDRESS IN C_A_
        203           7402          REC_LEN  EQU    CA+2                           ;RECORD LENGTH ADDRESS IN C_A_
        204           7408          BUFFER   EQU    CA+8                           ;I_O_BUFFER
        205           7401          RNAM_BUF EQU    CA+1                           ;RENAME BUFFER AREA
        206           7404          LOADADDR EQU    CA+4                           ;ADDRESS OF MEM ADDRESS OF OVERLAY
        207
        208           0080          MAXBUFLN EQU    128                            ;UP TO 128 WORDS MAY BE READ IN
        209           0004          ABSOLUTE EQU    004H                           ;FILE TYPE IS ABSOLUTE
        210           0081          OPEN     EQU    081H
        211           0082          CLOSE    EQU    082H
        212           0087          READ     EQU    087H
        213           0089          WRITE    EQU    089H
        214           008A          RENAME   EQU    08AH
        215
        216                         ;GLOBAL EQUATES
        217                         ;      INCLUDE equate file name
        218
        219
        220                                PROG
        221                                GLOBAL   TAPE_MANAGER
        222
        223                                GLOBAL   INITIALIZE_TAPE
        224   0000'                 INITIALIZE_TAPE:
        225                                GLOBAL   INIT_TAPE
        226   0000'                 INIT_TAPE:
        227   0000' 3E 00                    LD     A,0                            ;CLEAR THE HP64000 AREA

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   5

        228   0002' 32 0074                  LD     [CA],A
        229   0005' 32 0000#                 LD     [CSA],A                        ;AND THE TAPE CONTROL STATUS AREA
        230   0008' 3D                       DEC    A
        231   0009' 32 0000#                 LD     [OVERLAY_NUMBER],A             ;MAKE THE OVERLAY NUMBER -1 (INVALID)
        232   000C'                          NEXT_STATE 0                          ;SET THE IDLE STATE!
        233   000C' 3E 00       A            LD     A,0                          ;SOMETHING IN THE COMMAND BUFFER!
        234   000E' 32 0000#    A            LD     [TAPE_STATE],A
        235   0011' 2A 4100'    A            LD     HL,[STATE_VECTORS+0+0]
        236   0014' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        237   0017' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        238   001A' C9                       RET
        239
        240   001B'                 TAPE_MANAGER:
        241                         ;BEGIN        (Ordinarily registers are restored; retain only the pushes and pops you need.)
        242
        243   001B' 3A 0074                  LD     A,[CA]                         ;TEST THE STATUS OF THE FILE
        244   001E' B7                       OR     A
        245   001F' FA 6A01'                 JP     M,END_OF_STATE_MACHINE         ;IF THERE IS A COMMAND IN THE BUFFER
        246   0022' 28 05                    JR     Z,AB_REQ
        247   0024' FE 01                    CP     1                              ;END OF FILE ON READ FROM HP64000
        248   0026' C2 6C01'                 JP     NZ,ERROR
        249                         ;*
        250                         ;*        AT THIS POINT ANY SIM I/O FUNCTIONS ARE COMPLETE; TEST FOR ABORTS (KILLS)
        251                         ;*
        252                                  GLOBAL AB_REQ
        253   0029' 3A 0000#        AB_REQ:  LD     A,[CSA]                         ;IF COMMAND IS TO KILL TAPE COMMAND
        254   002C' FE ??                    CP     KILL_TAPE
        255   002E' 20 0D                    JR     NZ,CASE_STATE
        256   0030' 3A 0000#                 LD     A,[TAPE_STATE]                  ;CHECK THE STATE OF THE TAPE
        257                         ;*
        258   0033' FE 03                    CP     3                               ;CHECK STATE 0,1,2
        259   0035' DA 3D01'                 JP     C,STATE_PRE_IDLE                ;FILE NOT OPENED
        260                         ;*
        261   0038' FE 06                    CP     6                               ;STATE 3,4,5
        262   003A' DA 2A01'                 JP     C,STATE_CLOSE                   ;FILE OPENED TRY TO CLOSE IT
        263                         ;*
        264                         ;*               FALL THRU TO CASE STATEMENT     ;IF STATE = 6,7
        265                         ;*                                               ;FILE IS TRYING TO CLOSE
        266                         ;*
        267                         ;*
        268                         ;*        CASE   TAPE_STATE,(IDLE,RENAME,OPEN,READ1,READ2,MOVE2VRAM,CLOSE,PRE_IDLE)
        269                         ;*
        270   003D'                 CASE_STATE:
        271                         ;*
        272                         ;*
        273   003D' 2A 0000"                 LD     HL,[NEXT_STATE_ADDRESS]
        274   0040' E9                       JP     [HL]
        275   0041'                 STATE_VECTORS:
        276   0041' 5300'                    DEFW   STATE_IDLE                      ;STATE 0
        277   0043' 6800'                    DEFW   STATE_RENAME                    ;      1
        278   0045' A200'                    DEFW   STATE_OPEN                      ;      2
        279   0047' C200'                    DEFW   STATE_READ_1                    ;      3
        280   0049' DA00'                    DEFW   STATE_READ_2                    ;      4
        281   004B' F200'                    DEFW   STATE_MOVE2RAM                  ;      5
        282   004D' 2A01'                    DEFW   STATE_CLOSE                     ;      6
        283   004F' 3D01'                    DEFW   STATE_PRE_IDLE                  ;      7
        284   0051' 5401'                    DEFW   WRITE_1

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   6

        285                         ;*
        286                         ;*        IF THE MACHINE IS IDLE IT'S OK TO TEST FOR ANOTHER READ REQUEST
        287                         ;*
        288   0053'                 STATE_IDLE:                                     ;STATE 0
        289   0053' 3A 0000#                 LD     A,[CSA]                         ;TEST THE COMMAND STATUS AREA
        290   0056' B7                       OR     A
        291   0057' CA 6A01'                 JP Z,END_OF_STATE_MACHINE
        292                         ;*
        293   005A'                          NEXT_STATE 1
        294   005A' 3E 01       A            LD     A,1                          ;SOMETHING IN THE COMMAND BUFFER!
        295   005C' 32 0000#    A            LD     [TAPE_STATE],A
        296   005F' 2A 4300'    A            LD     HL,[STATE_VECTORS+1+1]
        297   0062' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        298   0065' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        299                         ;*
        300                         ;*        ASSIGN THE SIM I/O FILE TO THE CURRENT OVERLAY NAME
        301                         ;*
        302   0068'                 STATE_RENAME:                                   ;STATE 1
        303   0068' 3A 0000#                 LD     A,[OVERLAY_NUMBER]
        304   006B' 21 8701'                 LD     HL,SAMPLE_NAME
        305   006E' 11 0174                  LD     DE,RNAM_BUF                     ;POINT TO THE RENAME BUFFER IN THE COMMON ATTRIBUTES AREA
        306   0071' 01 0400                  LD     BC,SAMPLE_NAME_LEN              ;NO NAME COULD BE MORE THAN TEN BYTES LONG COULD IT?
        307   0074' ED B0                    LDIR                                   ;MOVE THE OVERLAY DATA TO THE RENAME BUFFER
        308                         ;*
        309                         ;*
        310                         ;*
        311   0076' 01 300A                  LD     BC,10*256+"0"                   ;GET THE OVERLAY NUMBER INTO ASCII
        312   0079'                 OV_2_ASCII_1:
        313   0079' B7                       OR     A
        314   007A' 98                       SBC    A,B                             ;DIVIDE OVERLAY NUMBER BY 10
        315   007B' 0C                       INC    C                               ;SET THE NUMBER OF TENS IN C (DOESN'T RESET CARRY)
        316   007C' 30 FB                    JR     NC,OV_2_ASCII_1                 ;CARRY WAS SET BY SUBTRACT IF B>A
        317   007E' 0D                       DEC    C                               ;SAVE THE TENS BYTE
        318   007F' 80                       ADD    A,B                             ;ADD TENS TO GET THE REMAINDER
        319   0080' 06 30                    LD     B,"0"                           ;SAVE THE ONES BYTE
        320   0082' 80                       ADD    A,B
        321   0083' 47                       LD     B,A
        322   0084' 79                       LD     A,C
        323   0085' FE 30                    CP     "0"                             ;CONVERT TO ASCII
        324   0087' 20 02                    JR     NZ,OV_2_ASCII_2
        325   0089' 3E 5F                    LD     A,"_"                           ;SPECIAL CASE
        326   008B'                 OV_2_ASCII_2:
        327   008B' 12                       LD     [DE],A                          ;DE IS POINTING TO THE FILENAME FROM THE LDIR ABOVE
        328   008C' 13                       INC    DE
        329   008D' 78                       LD     A,B
        330   008E' 12                       LD     [DE],A
        331                         ;*
        332                         ;*        ASSIGN THE FILE
        333                         ;*
        334   008F' 3E 8A                    LD     A,RENAME
        335   0091' 32 0074                  LD     [CA],A
        336                         ;*
        337   0094'                          NEXT_STATE 2                           ;NEXT OPEN
        338   0094' 3E 02       A            LD     A,2                          ;SOMETHING IN THE COMMAND BUFFER!
        339   0096' 32 0000#    A            LD     [TAPE_STATE],A
        340   0099' 2A 4500'    A            LD     HL,[STATE_VECTORS+2+2]
        341   009C' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   7

        342   009F' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        343                         ;*
        344                         ;*
        345   00A2'                 STATE_OPEN:                                     ;STATE 2
        346                         ;*
        347                         ;*        OPEN THE FILE
        348                         ;*
        349   00A2' 3E 04                    LD     A,ABSOLUTE                      ;LOAD THE FILE TYPE
        350   00A4' 32 0174                  LD     [FILETYPE],A
        351   00A7' 3E 00                    LD     A,0                             ;DISK NUMBER
        352   00A9' 32 0274                  LD     [DISC_NUM],A
        353   00AC' 3E 81                    LD     A,OPEN                          ;OPEN THE CURRENT FILE
        354   00AE' 32 0074                  LD     [CA],A
        355   00B1' 3A 0000#                 LD     A,[CSA]                         ;NEXT STATE READ OR WRITE?
        356   00B4'                          NEXT_STATE 3                           ;NEXT STATE = READ_1
        357   00B4' 3E 03       A            LD     A,3                          ;SOMETHING IN THE COMMAND BUFFER!
        358   00B6' 32 0000#    A            LD     [TAPE_STATE],A
        359   00B9' 2A 4700'    A            LD     HL,[STATE_VECTORS+3+3]
        360   00BC' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        361   00BF' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        362   00C2'                 STATE_READ_1:                                   ;STATE 3
        363                         ;*
        364                         ;*        READ THE FIRST RECORD TO SKIP OVER IT
        365                         ;*
        366   00C2' 3E 80                    LD     A,MAXBUFLN                      ;SET THE INPUT BUFFER LENGTH
        367   00C4' 32 0174                  LD     [BUF_LEN],A                     ;
        368   00C7' 3E 87                    LD     A,READ
        369   00C9' 32 0074                  LD     [CA],A                          ;READ THE FIRST RECORD
        370
        371   00CC'                          NEXT_STATE 4
        372   00CC' 3E 04       A            LD     A,4                          ;SOMETHING IN THE COMMAND BUFFER!
        373   00CE' 32 0000#    A            LD     [TAPE_STATE],A
        374   00D1' 2A 4900'    A            LD     HL,[STATE_VECTORS+4+4]
        375   00D4' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        376   00D7' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        377
        378                         ;*
        379                         ;*        READ REMAINING RECORDS AND MOVE TO RAM
        380                         ;*
        381   00DA'                 STATE_READ_2:                                   ;STATE 4
        382   00DA' 3E 80                    LD     A,MAXBUFLN                      ;SET THE INPUT BUFFER LENGTH
        383   00DC' 32 0174                  LD     [BUF_LEN],A                     ;
        384   00DF' 3E 87                    LD     A,READ                          ;
        385   00E1' 32 0074                  LD     [CA],A
        386
        387   00E4'                          NEXT_STATE 5                           ;NEXT STATE = READ A DATA RECORD
        388   00E4' 3E 05       A            LD     A,5                          ;SOMETHING IN THE COMMAND BUFFER!
        389   00E6' 32 0000#    A            LD     [TAPE_STATE],A
        390   00E9' 2A 4B00'    A            LD     HL,[STATE_VECTORS+5+5]
        391   00EC' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        392   00EF' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        393
        394                         ;*
        395                         ;*        MOVE THE LAST BUFFER TO RAM
        396                         ;*
        397   00F2'                 STATE_MOVE2RAM:                                 ;STATE 5
        398   00F2' 3A 0074                  LD     A,[CA]                          ;CHECK THE RETURN STATUS

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   8

        399   00F5' B7                       OR     A
        400   00F6' 28 0E                    JR     Z,NO_EOF                        ;END OF FILE?
        401                         ;*
        402                         ;*
        403
        404   00F8'                          NEXT_STATE 6                           ;NEXT STATE = CLOSE FILE
        405   00F8' 3E 06       A            LD     A,6                          ;SOMETHING IN THE COMMAND BUFFER!
        406   00FA' 32 0000#    A            LD     [TAPE_STATE],A
        407   00FD' 2A 4D00'    A            LD     HL,[STATE_VECTORS+6+6]
        408   0100' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        409   0103' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        410   0106'                 NO_EOF:                                         ;MOVE THE CURRENT OVERLAY TO MEMORY
        411   0106' 2A 0274                  LD     HL,[REC_LEN]                    ;GET THE NUMBER OF BYTES TO MOVE TO RAM
        412   0109' 4C                       LD     C,H
        413   010A' 45                       LD     B,L
        414                         ;*
        415   010B' 2A 0474                  LD     HL,[LOADADDR]                   ;GET THE LOAD ADDRESS AND CHECK TO SEE IF IT IS IN VRAM
        416   010E' 55                       LD     D,L
        417   010F' 5C                       LD     E,H
        418   0110' 21 0874                  LD     HL,BUFFER                       ;FROM ADDRESS
        419
        420   0113' 3A 0000#                 LD     A,[CSA]
        421   0116' FE ??                    CP     WRITE_TAPE
        422   0118' 28 3A                    JR     Z,WRITE_1
        423
        424   011A' ED B0                    LDIR
        425                         ;*
        426
        427   011C'                          NEXT_STATE 4                           ;NEXT STATE = READ A DATA RECORD
        428   011C' 3E 04       A            LD     A,4                          ;SOMETHING IN THE COMMAND BUFFER!
        429   011E' 32 0000#    A            LD     [TAPE_STATE],A
        430   0121' 2A 4900'    A            LD     HL,[STATE_VECTORS+4+4]
        431   0124' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        432   0127' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        433                         ;*
        434                         ;*        CLOSE OVERLAY FILE
        435                         ;*
        436   012A'                 STATE_CLOSE:                                    ;STATE 6
        437   012A' 3E 82                    LD     A,CLOSE                         ;CLOSE THE FILES
        438   012C' 32 0074                  LD     [CA],A
        439
        440   012F'                          NEXT_STATE 7                           ;NEXT STATE = PRE-IDLE
        441   012F' 3E 07       A            LD     A,7                          ;SOMETHING IN THE COMMAND BUFFER!
        442   0131' 32 0000#    A            LD     [TAPE_STATE],A
        443   0134' 2A 4F00'    A            LD     HL,[STATE_VECTORS+7+7]
        444   0137' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        445   013A' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        446                         ;*
        447                         ;*
        448                         ;*        NEXT STATE IS IDLE
        449                         ;*
        450   013D'                 STATE_PRE_IDLE:                                 ;STATE 7
        451   013D' 3E 00                    LD     A,0                             ;NEXT STATE = PRE-IDLE
        452   013F' 32 0000#                 LD     [CSA],A                         ;CLEAR THE COMMAND STATUS BUFFER
        453   0142' 3D                       DEC    A
        454   0143' 32 0000#                 LD     [OVERLAY_NUMBER],A              ;SET THE OVERLAY NUMBER TO OUT OF RANGE
        455   0146'                          NEXT_STATE 0

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page   9

        456   0146' 3E 00       A            LD     A,0                          ;SOMETHING IN THE COMMAND BUFFER!
        457   0148' 32 0000#    A            LD     [TAPE_STATE],A
        458   014B' 2A 4100'    A            LD     HL,[STATE_VECTORS+0+0]
        459   014E' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        460   0151' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        461                         ;*
        462                         ;*        WRITE OUT 256 DATA BYTES TO AN OVERLAY! OH BOY!
        463                         ;*
        464   0154'                 WRITE_1:                                        ;GET HERE FROM MOVE2RAM1
        465   0154' EB                       EX     DE,HL
        466   0155' ED B0                    LDIR
        467   0157' 3E 89                    LD     A,WRITE
        468   0159' 32 0074                  LD     [CA],A
        469   015C'                          NEXT_STATE 6
        470   015C' 3E 06       A            LD     A,6                          ;SOMETHING IN THE COMMAND BUFFER!
        471   015E' 32 0000#    A            LD     [TAPE_STATE],A
        472   0161' 2A 4D00'    A            LD     HL,[STATE_VECTORS+6+6]
        473   0164' 22 0000"    A            LD     [NEXT_STATE_ADDRESS],HL
        474   0167' C3 6A01'    A            JP     END_OF_STATE_MACHINE
        475                         ;*
        476                         ;*
        477                         ;*
        478
        479                         ;  END (TAPE_MANAGER)
        480
        481   016A'                 END_OF_STATE_MACHINE:
        482   016A' AF                     XOR A
        483   016B' C9                     RET
        484                         ;***************************************************************************
        485                         ;***************************************************************************
        486   016C'                 ERROR:
        487                         ;  BEGIN       (Ordinarily registers are restored; retain only the pushes and pops you need.)
        488
        489   016C' 4F                     LD C,A
        490   016D' 3A 0000#               LD A,[OVERLAY_NUMBER]                    ;SAVE THE OVERLAY NUMBER IN A
        491   0170' 47                     LD B,A
        492   0171' 3A 0000#               LD A,[TAPE_STATE]
        493   0174' 21 0000                LD HL,0                                  ;B HAS THE FUNCTION CODE
        494   0177' 77                     LD [HL],A                                ;C HAS THE ERROR CODE
        495                         ;
        496                         ;   LD [HL] HAS JUST CAUSED A BINK TO OCCUR ON THE HP64000
        497                         ;   THIS IS TO LET THE USER KNOW THERE HAS BEEN AN ERROR
        498                         ;
        499   0178' AF                     XOR     A
        500   0179' 32 0074                LD      [CA],A                           ;CLEAR THE ERROR FROM THE HP64000
        501   017C' 3C                     INC     A                                ;PRETEND THE ERROR WAS A CRC CHECK FROM ADAM'S TAPE
        502   017D' 32 0000#               LD      [CSA],A
        503   0180' 2A 4100'               LD      HL,[STATE_VECTORS+0000]
        504   0183' 22 0000"               LD      [NEXT_STATE_ADDRESS],HL
        505   0186' C9                     RET
        506
        507                         ;  END (TAPE_ERR)
        508
        509                         ;***************************************************************************
        510                         ;***************************************************************************
        511                         ;
        512                         ;   OVERLAY NAMES

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page  10

        513                         ;
        514                         ;         -------- -------- -------- -------- --------
        515                         ;        :LENGTH  :FILENAME ------> : USER ID         :
        516                         ;        :BYTE    :UP TO 9 BYTES    : UP TO 5 BYTES   :
        517                         ;         -------- -------- -------- -------- --------
        518                         ;        LENGTH_BYTE := (((((LENGTH OF FILE NAME)+1)/2)-1)*32) + ((LENGTH OF USER ID)/2)*8)
        519                         ;        FILENAME MUST BE ODD NUMBER OF BYTES LONG MAY BE PADDED WITH ONE SPACE.
        520                         ;        USER ID MUST BE EVEN NUMBER OF BYTES LONG MAY BE PADDED WITH ONE SPACE.
        521                         ;
        522                         ;*****************************************************************************************
        523                         ;*****************************************************************************************
        524                         ;*
        525                         ;*  OVERLAY NAME 0
        526                         ;*
        527   0187'                 SAMPLE_NAME
        528   0187' 40              OVLAY0   DEFB   FL_NM_LN0*32+US_ID_LN0*8        ;LENGTH DESCRIPTION BYTE
        529   0188' 4F 56 4C 5F     NAM_0    DEFB   "OVL_1"                         ;MUST BE ODD NUMBER OF LETTERS
        530   018C' 31
        531   018D'                 USID0    DEFB   ""                              ;MUST BE EVEN NUMBER OF LETTERS
        532           0002          FL_NM_LN0 EQU   ((USID0-NAM_0+1)/2)-1           ;LENGTH OF FILENAME IN WORDS
        533           0000          US_ID_LN0 EQU   ($-USID0)/2                     ;LENGTH OF USERID IN WORDS
        534           0004          SAMPLE_NAME_LEN EQU $-SAMPLE_NAME-2             ;NUMBER OF BYTES TO MOVE = 4
        535                         ;***********************************************************************
        536                          DATA
        537                          GLOBAL NEXT_STATE_ADDRESS
        538   0000"   0002          NEXT_STATE_ADDRESS DEFS 2                       ;POINTER TO NEXT ENTRY STATE
        539   0002"   0001          DEVICE_ID          DEFS 1                       ;DEVICE INDEPENDENCE SIMULATED

         0 Error(s) Detected.   397 Program Bytes.     3 Data Bytes.
        49 Symbols Detected.

    FILE: TAPE_MANA:TOS      HEWLETT-PACKARD: TAPE_MANAGER  (c) Coleco 1983 Confidential           Tue, 15 May 1984, 20:30     Page  11

    Value   Symbol          Defined         Referenced:

    0004  ABSOLUTE             209     349
    0029' AB_REQ               253     246   252
    7408  BUFFER               204     418
    7401  BUF_LEN              200     367   383
    7400  CA                   199     200   201   203   204   205   206   228   243   335   354   369   385   398   438   468   500
    003D' CASE_STATE           270     255
    0082  CLOSE                211     437
    0000# CSA                          191   229   253   289   355   420   452   502
    0002" DEVICE_ID            539     196
    7402  DISC_NUM             202     352
    016A' END_OF_STATE_MACHINE
                               481     237   245   291   298   342   361   376   392   409   432   445   460   474
    016C' ERROR                486     248
    7401  FILETYPE             201     202   350
    0002  FL_NM_LN0            532     528
    0000' INITIALIZE_TAPE      224     223
    0000' INIT_TAPE            226     225
    0000# KILL_TAPE                    189   254
    7404  LOADADDR             206     415
    0080  MAXBUFLN             208     366   382
    0188' NAM_0                530     532
    0000" NEXT_STATE_ADDRESS
                               538     236   273   297   341   360   375   391   408   431   444   459   473   504   537
    0106' NO_EOF               410     400
    0081  OPEN                 210     353
    0000# OVERLAY_NUMBER               193   231   303   454   490
    0187' OVLAY0               528
    0079' OV_2_ASCII_1         312     316
    008B' OV_2_ASCII_2         326     324
    0087  READ                 212     368   384
    7402  REC_LEN              203     411
    008A  RENAME               214     334
    7401  RNAM_BUF             205     305
    0187' SAMPLE_NAME          527     304   534
    0004  SAMPLE_NAME_LEN      534     306
    012A' STATE_CLOSE          436     262   282
    0053' STATE_IDLE           288     276
    00F2' STATE_MOVE2RAM       397     281
    00A2' STATE_OPEN           345     278
    013D' STATE_PRE_IDLE       450     259   283
    00C2' STATE_READ_1         362     279
    00DA' STATE_READ_2         381     280
    0068' STATE_RENAME         302     277
    0041' STATE_VECTORS        275     235   296   340   359   374   390   407   430   443   458   472   503
    001B' TAPE_MANAGER         240     221
    0000# TAPE_STATE                   192   234   256   295   339   358   373   389   406   429   442   457   471   492
    018D' USID0                531     532   533
    0000  US_ID_LN0            533     528
    0089  WRITE                213     467
    0154' WRITE_1              464     284   422
    0000# WRITE_TAPE                   190   421